package com.binhai.springboot.role.controller;

import com.binhai.springboot.role.bean.RoleBean;
import com.binhai.springboot.role.servie.RoleService;

import com.binhai.springboot.user.bean.UserBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService service;

    @RequestMapping("/toMain.do")
    public String toMain(){

        return "role/main";
    }

    @RequestMapping("/getAllData.do")
    @ResponseBody
    public List getAllData(){

        return service.getAllData();
    }


    @RequestMapping("/saveData.do")
    @ResponseBody
    public Map saveData(@RequestBody RoleBean bean){

        return service.saveData(bean);
    }

    @RequestMapping("/saveShouQuan.do")
    @ResponseBody
    public Map saveShouQuan(@RequestBody RoleBean bean){

        return service.saveShouQuan(bean);
    }

    @RequestMapping("/updateData.do")
    @ResponseBody
    public Map updateData(@RequestBody RoleBean bean){

        return service.updateData(bean);
    }
    @RequestMapping("/deleteData.do")
    @ResponseBody
    public Map deleteData(@RequestBody RoleBean bean){

        return service.deleteData(bean);
    }

    @RequestMapping("/getShouQuan.do")
    @ResponseBody
    public String getShouQuan(@RequestBody  RoleBean bean){

        return service.getShouQuan(bean);
    }

    @RequestMapping("/selectData.do")
    @ResponseBody
    public List selectData(@RequestBody RoleBean bean){

        return service.selectData(bean.getName ());
    }

    /**
     * 加载看角色树
     * @return
     */
    @RequestMapping("/getAllRoleTreeData.do")
    @ResponseBody
    public List getAllRoleTreeData(){
        return service.getAllRoleTreeData();
    }
}
